package cn.jbolt.user.auth.api;

import cn.jbolt.core.api.JBoltApiBaseController;
import cn.jbolt.core.api.httpmethod.JBoltHttpGet;
import cn.jbolt.core.cache.JBoltPermissionCache;
import cn.jbolt.core.cache.JBoltTopnavCache;
import cn.jbolt.core.crossorigin.CrossOrigin;
import cn.jbolt.core.kit.JBoltUserKit;
import cn.jbolt.core.permission.JBoltApiAuthInterceptor;
import cn.jbolt.core.permission.UnCheck;
import cn.jbolt.core.permission.UnCheckIfSystemAdmin;
import com.jfinal.aop.Before;
import com.jfinal.core.Path;

/**
 * 用户持有权限api
 */
@CrossOrigin
@UnCheck
@Path("/api/user/permission")
public class JBoltUserPermissionApiController extends JBoltApiBaseController {
    //public void topnavs(){
    //    renderJBoltApiSuccessWithData(
    //            JBoltTopnavCache.me.getCurrentUserTopNavs()
    //    );
    //}

    /**
     * 用户持有菜单
     */
    public void menus(){
        renderJBoltApiSuccessWithData(
                JBoltPermissionCache.me.getCurrentUserMenus()
        );
    }

    /**
     * 获取当前调用api的jbuser的所有权限keys
     */
    @JBoltHttpGet
    public void keys(){
        renderJBoltApiSuccessWithData(
                JBoltPermissionCache.me.getCurrentUserAllEnablePermissionKeys()
        );
    }
}
